import { reqgetHomeHotSuggests, reqgetHomeCategories, reqgetHouseList } from "@/services";
import { defineStore } from "pinia";

const useHomeStore = defineStore('home', {
    state: () => {
        return {
            hotSuggests: [],   //热门建议
            categories: [],     //推荐类别
            currentPage: 1,
            houselist: []   //热门精选
        }
    },
    actions: {
        // 热门建议
        async getHomeHotSuggests(){
            const res = await reqgetHomeHotSuggests()
            this.hotSuggests = res.data
        },
        // 推荐类别
        async getHomeCategories(){
            const res = await reqgetHomeCategories()
                this.categories = res.data
        },
        // 热门精选
        async getHouseList(){
            const res = await reqgetHouseList(this.currentPage)
            this.houselist.push(...res.data)
            this.currentPage++
        }
    }
})

export default useHomeStore